<template>
	<view>
		<view class="alldiv">
			<view class="headdiv">
				<cover-image class="back" @click="returns" src="@/static/image/arrow-left.png"></cover-image>
			</view>

			<view class="bodydiv">
				<!-- 订单信息 -->
				<view class="order-info">
					<view class="title">
						{{ language.Takingataxi.orderCancelSuccess }}
					</view>
					<view class="tip">
						{{ language.Takingataxi.takeNewTaxi }}
					</view>
				</view>

				<!-- 地址信息 -->
				<view class="address-box">
					<view class="date">
						<u-icon style="marginRight: 16rpx;" name="clock-fill" size="12"></u-icon>
						{{ orderInfo.endTime }}
					</view>
					<view class="origin-station">
						{{ orderInfo.startPlace }}
					</view>
					<view class="destination">
						{{ orderInfo.endPlace }}
					</view>
				</view>

				<!-- 司机信息 -->
				<view class="driver-info">
					<view class="profile-photo mr10">
						<u-avatar :src="driverInfo.headPortrait"></u-avatar>
					</view>
					<view class="driver-name mr10">{{ driverInfo.name }}师傅</view>
					<view class="license-plate mr10">{{ driverInfo.licensePlateNum }}</view>
					<view class="taxi-type">快车</view>
				</view>

				<!-- 帮助 -->
				<view class="other-use">
					<view class="other-use-item" v-for="item in otherUseList" :key="item.id">
						<u-icon :name="item.icon" size="12"></u-icon>
						<view class="name">{{ item.name }}</view>
					</view>
				</view>

				<!-- 重新打车 -->
				<view class="takeNewTaxi">
					<u-button class="takeNewTaxi-btn" @click="takeTaxiNew"
						shape="square">{{ language.Takingataxi.takeNewTaxi }}</u-button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import * as driverApi from '@/api/driver.js'
	export default {
		data() {
			return {
				latitude: {},
				orderInfo: {},
				driverInfo: {},
				otherUseList: [{
						id: 1,
						icon: require('@/static/image/path.png'),
						name: '投诉反馈',
					}, {
						id: 0,
						icon: require('@/static/image/seek-help.png'),
						name: '紧急求助',
					},
					{
						id: 2,
						icon: require('@/static/image/share.png'),
						name: '联系客服',
					},
				]
			}
		},
		onShow: function() {
			this.getlanguagedata();
		},
		onLoad(option) {
			console.log(option, 'option')
			if (!option.orderId) {
				this.returns()
			}
			try {
				uni.showLoading({
					title: 'loading...'
				});
				driverApi.getTaxiOrder({
					id: option.orderId,
				}).then(res => {
					if (res.code === 0) {
						this.orderInfo = res.data
						driverApi.getDriverInfo({
							id: res.data.driverId
						}).then(res => {
							if (res.code === 0) {
								this.driverInfo = res.data
							}
						})
					}
					uni.hideLoading();
				})
			} catch (error) {
				console.log(error)
				uni.hideLoading();
			}
		},
		mounted() {},
		methods: {
			getlanguagedata() {
				this.language =
					this.$store.getters["internationalization/getinternationalization"];
			},
			takeTaxiNew() {
				const startPointObj = {
					address: this.orderInfo.startPlace,
					latitude: this.orderInfo.startLatitude,
					longitude: this.orderInfo.startLongitude
				}
				const endLocation = {
					address: this.orderInfo.endPlace,
					latitude: this.orderInfo.endLatitude,
					longitude: this.orderInfo.endLongitude
				}
				uni.navigateTo({
					url: "/pages/Home/Takingataxi/index",
				});
				// uni.navigateTo({
				// 	url: `/pages/Home/Takingataxi/TakingataxiNow?startLocation=${encodeURIComponent(JSON.stringify(startPointObj))}&endLocation=${encodeURIComponent(JSON.stringify(endLocation))}`
				// });
			},
			returns() {
				uni.navigateTo({
					url: "/pages/Home/Takingataxi/index",
				});
			}
		}
	}
</script>

<style lang="less" scoped>
	.alldiv {
		width: 100%;
		height: 100vh;

		.headdiv {
			position: relative;
			width: 100%;
			height: 524rpx;
			overflow: hidden;

			.map {
				// 隐藏选中时的div边框
				width: calc(100% + 4px);
				height: calc(100% + 4px);
				outline: none;
				margin: -2px 0 0 -2px;
			}

			.back {
				position: absolute;
				left: -40rpx;
				top: 100rpx;
				width: 160rpx;
				height: 120rpx;
				transform: scale(0.5)
			}
		}

		.bodydiv {
			// margin-top: -20rpx;
			padding: 48rpx 32rpx;
			width: 100%;
			height: calc(100vh - 504rpx);
			border-radius: 20px 20px 0 0;
			background: rgba(255, 255, 255, 1);
			box-shadow: 0px -3px 6px rgba(6, 145, 161, 0.05);
			overflow-y: auto;

			// 订单信息
			.order-info {
				.title {
					font-size: 32rpx;
					font-weight: bold;
					line-height: 44rpx;
					color: rgba(56, 56, 56, 1);
				}

				.tip {
					margin-top: 8rpx;
					font-size: 20rpx;
					line-height: 28rpx;
					color: rgba(59, 167, 255, 1);
				}
			}

			// 地址信息
			.address-box {
				margin-top: 20rpx;
				border-radius: 16px;
				background: rgb(255, 255, 255);
				box-shadow: 0px 2px 4px rgba(5, 48, 7, 0.1);
				padding: 28rpx 24rpx;
				font-size: 24rpx;
				line-height: 32rpx;
				color: rgba(102, 102, 102, 1);

				.date {
					display: flex;
					align-items: center;
				}

				.origin-station {
					position: relative;
					display: flex;
					align-items: center;
					margin: 12rpx 0;

					&::before {
						content: '';
						display: block;
						margin: 0 20rpx 0 6rpx;
						width: 6px;
						height: 6px;
						border-radius: 50%;
						background: rgb(47, 212, 184);
					}

					&::after {
						position: absolute;
						left: 11rpx;
						top: 28rpx;
						content: '';
						display: block;
						height: 20rpx;
						width: 2rpx;
						background: rgb(217, 219, 218);
						;
					}
				}

				.destination {
					display: flex;
					align-items: center;

					&::before {
						content: '';
						display: block;
						margin: 0 20rpx 0 6rpx;
						width: 6px;
						height: 6px;
						border-radius: 50%;
						background: rgb(255, 141, 26)
					}
				}
			}

			// 司机信息
			.driver-info {
				position: relative;
				padding: 28rpx 0 0;
				margin-top: 24rpx;
				display: flex;
				align-items: center;
				color: #333;
				font-weight: bold;
				font-size: 28rpx;
				line-height: 40rpx;

				.profile-photo {
					width: 80rpx;
					height: 80rpx;
				}

				.taxi-type {
					width: 56rpx;
					height: 28rpx;
					text-align: center;
					line-height: 28rpx;
					border-radius: 2px;
					background: linear-gradient(135deg, rgb(255, 141, 26) 0%, rgb(255, 82, 82) 100%);
					color: #fff;
					font-size: 20rpx;
				}

				.contact-driver {
					position: absolute;
					right: 0;
					width: 60rpx;
					height: 60rpx;
					display: flex;
					align-items: center;
					justify-content: center;
					text-decoration: none;
					border-radius: 50%;
					background: rgb(255, 255, 255);
					box-shadow: 0px 2px 4px rgba(5, 48, 7, 0.08);
				}
			}

			.mr10 {
				margin-right: 20rpx;
			}

			// 其他操作
			.other-use {
				display: flex;
				justify-content: center;

				.other-use-item {
					display: flex;
					flex-direction: column;
					align-items: center;
					justify-content: center;
					width: 184rpx;
					padding: 34rpx 0;
					border-radius: 8rpx;
					background: rgb(255, 255, 255);

					.name {
						margin-top: 8rpx;
						color: rgba(102, 102, 102, 1);
						font-size: 24rpx;
						line-height: 32rpx;
					}
				}
			}

			.takeNewTaxi {
				position: fixed;
				bottom: 0;
				left: 0;
				width: 100%;
				height: 236rpx;
				padding: 48rpx 70rpx;
				border-radius: 20px 20px 0px 0px;
				background: rgb(255, 255, 255);
				box-shadow: 0px -3px 6px rgba(5, 48, 7, 0.08);

				.takeNewTaxi-btn {
					height: 88rpx;
					border-radius: 60rpx;
					background: linear-gradient(90deg, rgb(65, 240, 135) 0%, rgb(47, 212, 184) 100%);
					box-shadow: 0px -3px 6px rgba(5, 48, 7, 0.08);
					color: #fff;
					font-size: 32rpx;
					font-weight: bold;
				}
			}
		}
	}
</style>